#include <stack>
#include <iostream>
#include <sstream>
#include <vector>

int main()
{
    std::string istr;
    std::getline(std::cin, istr);
    std::istringstream iss(istr);

    std::stack<int> sk;
    std::stack<int> sk_tmp;

    std::vector<int> ivec;
    int num;
    while (iss >> num)
    {
        ivec.push_back(num);
    }

    sk.push(ivec[0]);

    for (int i = 1; i < ivec.size(); i++)
    {
        num = ivec[i];
        int smv = 0;
        bool flag = true;
        while (!sk.empty())
        {
            int v = sk.top();
            sk.pop();
            sk_tmp.push(v);
            smv += v;
            // std::cout << "smv: " << smv << ", num:" << num << std::endl;

            if (smv - num > 0)
            {
                while (!sk_tmp.empty())
                {
                    sk.push(sk_tmp.top());
                    sk_tmp.pop();
                }
                sk.push(num);
                flag = false;
                break;
            }
            else if (smv - num == 0)
            {
                num = 2 * num;
                smv = 0;
                while (!sk_tmp.empty())
                {
                    sk_tmp.pop();
                }
            }
        }
        if (flag)
        {
            while (!sk_tmp.empty())
            {
                sk.push(sk_tmp.top());
                sk_tmp.pop();
            }

            sk.push(num);
        }
    }

    std::vector<int> rem;
    while (!sk.empty())
    {
        rem.push_back(sk.top());
        sk.pop();
    }

    for (int i = 0; i < rem.size() - 1; i++)
    {
        std::cout << rem[i] << " ";
    }
    std::cout << rem.back() << std::endl;

    return 0;
}